#定时任务
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab

# 设置Django的settings模块
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

# 配置定时任务
app.conf.beat_schedule = {
    'count-computers-statistics': {
        'task': 'computer.tasks.count_computers_statistics',
        'schedule': crontab(minute=0, hour=0),
        # 'schedule': crontab(minute='*/1'),  # 每分钟执行一次测试用
        'args': ()
    },
}



